﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using BusinessLayer.Model.Services;
using BusinessLayer;
using BusinessLayer.Model.Services.Abstract;
using BusinessLayer.Model.Services.Concrete;
using DataAccess.Services.Abstract;

namespace intecnologia.Admin
{
    public partial class Errors : System.Web.UI.Page
    {
        ISessionService _sessionService = new SessionService();
        IApplicationService _applicationService = new ApplicationService();

        protected void Page_Load(object sender, EventArgs e)
        {
            if (_sessionService.SessionExpired())
                Response.Redirect("~/Default.aspx");

            LoadErrorLog();
        }

        private void LoadErrorLog()
        {
            string errorFilePath = _applicationService.LogsFolder + Constants.ErrorHtmlLogFile;

            if (System.IO.File.Exists(errorFilePath))
                ErrorsPanel.Controls.Add(new LiteralControl(System.IO.File.ReadAllText(errorFilePath)));
        }
    }
}
